<!DOCTYPE HTML>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
		<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
		<link rel="stylesheet" type="text/css" href="../../css/api.css" />
		<link rel="stylesheet" type="text/css" href="../../css/style.css" />
		<style type="text/css">
			html,body{
				background-color: transparent !important; height:100%;
			}
			.detial_box{ position:fixed; left: 50%; margin-left: -130px; top: 50%; margin-top: -130px; width: 260px; padding-top: 20px; text-align: center; background-color: #fff; border-radius: 4px; z-index: 11; box-sizing: border-box; overflow: hidden;}
			.detial_box img{ margin:0 auto; width: 50px;}
			.detial_box b{ display:block; font-size: 18px; font-weight: 500; color: #333; line-height: 20px; padding-top: 10px;}
			.detial_box p{ font-size: 14px; color: #9F9F9F; padding: 5px 0 15px;}
			.detial_box button{ display:block; border: 0; position: relative; border-radius: 0; background-color: transparent; width: 100%; height: 50px; font-size: 14px; color: #1c63fa;}
			.detial_box button::after{ position:absolute; content: ""; left: 0; top: 0; right: 0; border-top: 1px #f0f0f0 solid; transform: translateY(0.5);}
			.detial_box input{ display:block; border: 0; font-size: 14px; color: #474747; padding: 13px; width: 80%; margin:0 auto; background-color: #F2F3F5; border-radius: 4px;}
			
			.detial_box .btn{ position:relative; height: 50px; margin-top:15px;}
			.detial_box .btn::after{ position:absolute; content: ""; left: 0; top: 0; right: 0; border-top: 1px #d4d4d4 solid; transform: scaleY(0.5);}
			.detial_box .btn::before{ position:absolute; content: ""; left: 50%; top: 0; bottom: 0; border-right: 1px #d4d4d4 solid; transform: scaleX(0.5);}
			.detial_box .btn button{ display:block; float: left; border: 0; width: 50%; text-align: center; font-size: 15px; color: #333; height: 50px; background-color: transparent; border-radius: 0;}
			.detial_box .btn button.on{ color:#1c63fa;}
		</style>
	</head>
	<body>
		<div id="filter" style="height:100%;">
		<div id="content">
		<div class="detial_box">
			<b id="title">支付定金</b>
			<p id="msg">请与货主确认定金金额</p>
			<p><input type="number" id="depositfee" name="depositfee" oninput="inputmaxlimit(this,1000.1);" onkeyup="checknumAndOnePoint(this)" value="" placeholder="请填写定金金额，不能低于50" /></p>
			<ul class="btn">
				<button tapmode="btnpress" onclick="closeframe();">取消</button>
				<button tapmode="btnpress" onclick="setFee();" class="on">确定</button>
			</ul>
		</div>
		</div>
		</div>
	</body>
	<script type="text/javascript" src="../../script/api.js" ></script>
	<script type="text/javascript" src="../../script/app.js" ></script>
	<script type="text/javascript" src="../../script/doT.js"></script>
	<script type="text/javascript">
		var msg,title;
		apiready = function() {
			api.parseTapmode();
			//点击空白处移除Frame
			
			var myDiv = document.getElementById("filter");
			myDiv.addEventListener("touchstart",function(){
				//api.closeFrame({
					//name: api.frameName
				//});
				
			});
			var myDiv1 = document.getElementById("content");
			myDiv1.addEventListener("touchstart",function(event){
				event=event||window.event;
				event.stopPropagation();
			});

			
			
		}
		function isRealNum(val){
			if(val === "" || val ==null){
				return false;
			}
			if(!isNaN(val)){
				return true;
			}else{
				return false;
			}
		}
		function checknumAndOnePoint(obj) {
			//只允许整数和一位小数
			//var v = $api.val(obj);
			obj.value = obj.value.replace(/[^\d.]/g,""); //先把非数字的都替换掉，除了数字和. 
			obj.value = obj.value.replace(/^\./g,""); //必须保证第一个为数字而不是. 
			obj.value = obj.value.replace(/\.{2,}/g,"."); //保证只有出现一个.而没有多个. 
			obj.value = obj.value.replace(".","$#$").replace(/\./g,"").replace("$#$","."); //保证.只出现一次，而不能出现两次以上 
			if(obj.value.indexOf(".") > -1)
			{
				obj.value = obj.value.substr(0,obj.value.indexOf(".")+2); 
			}			
			//if(!/^\d+(\.\d{1,2})?$/.test(obj.value))
			//{
				//obj.value = '';
				//toast('只能输入整数和一位小数');
			//}
			
		}
		function inputmaxlimit(obj,maxval) {
			//限制输入框字数
			if(!isRealNum(obj.value))
			{
				if(obj.value != ''){
				obj.value = obj.value.substr(0,obj.value.length-1);
				}
			}
			else
			{
				if(obj.value >= maxval) {
					obj.value = obj.value.substr(0,obj.value.length-1);
				}
			}
		}
		function setFee() {
			var depositfee = $api.val($api.byId('depositfee'));
			var re = /^[1-9]+[0-9]*]*$/;
			if (depositfee == '')
			{
				toast("请输入定金金额");
				return false;
			}
			if (!re.test(depositfee))
			{
				toast("定金金额只能输入整数");
				return false;
			}
			if (depositfee < 50)
			{
				toast("定金金额不能小于50");
				return false;
			}
			if (depositfee > 1000)
			{
				toast("定金金额不能大于1000");
				return false;
			}
			api.execScript({
				name: 'goodsdetail_win',
				script: 'setPaymoney(\''+depositfee+'\');'
			});
			closeframe();
		}
		function closeframe() {
			api.closeFrame({
				name: api.frameName
			});
		}
	</script>
</html>